<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>[|.pageTitle|]</title>
    [|if .zTree|]
    <link rel="stylesheet" href="/static/zTree3/css/demo.css?t=5" type="text/css">
    <link rel="stylesheet" href="/static/zTree3/css/zTreeStyle/zTreeStyle.css" type="text/css">
    [|end|]
    <meta charset="utf-8">
    <link rel="stylesheet" href="/static/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="/static/css/main.css">
    <script src="/static/layui/layui.js?s=36"></script>
    <script src="/static/js/main.js?s=2124"></script>
</head>
<body>
<div class="layui-layout layui-layout-admin" style="padding-left: 40px;margin-top: 20px;">
<form class="layui-form" >
    <div class="layui-form-item">
        <label class="layui-form-label" style="display:inline-block;width:150px;">房间信息：</label>
      <div class="layui-input-inline">
        <select name="roomslist" id = "roomslist" lay-verify="required" lay-search="" lay-filter="fiterroominfolist" >
        </select>
      </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label"  style="display:inline-block;width:150px;">当前负分吃分作弊率：</label>
        <div class="layui-form-mid">
           [|.RoomInfo.MinusCheatRate|]
        </div>
      
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label"  style="display:inline-block;width:150px;">当前吃分作弊率：</label>
        <div class="layui-form-mid">
            [|.RoomInfo.EatCheatRate|]
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label"  style="display:inline-block;width:150px;">当前吐分作弊率：</label>
        <div class="layui-form-mid">
            [|.RoomInfo.VomitCheatRate|]
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label"  style="display:inline-block;width:150px;">血池平衡值：</label>
        <div class="layui-form-mid">
            [|.RoomInfo.RoomBloodBalance|]
        </div>
    </div>

     <div class="layui-form-item">
        <label class="layui-form-label"  style="display:inline-block;width:150px;">当前税率：</label>
        <div class="layui-form-mid">
            [|.RoomInfo.TaxRate|]
        </div>
    </div>
     <div class="layui-form-item">
        <label class="layui-form-label"  style="display:inline-block;width:150px;">机器人：</label>
        <div class="layui-form-mid">
            [|.RoomInfo.RobotCount|]
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label" style="display:inline-block;width:150px;">负分吃分作弊率：</label>
        <div class="layui-input-inline">
            <input  class="layui-input" type="number" name="Minus_Cheat_Rate" id="Minus_Cheat_Rate" autocomplete="off"  min ="-1000" max="1000" value="[|.RoomInfo.MinusCheatRate|]">
        </div>
        <div class="layui-form-mid layui-word-aux">
            <font color="#FF0000" size = "2">
                *该值是千分比，-1000到1000
            </font>
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label" style="display:inline-block;width:150px;">吃分作弊率：</label>
        <div class="layui-input-inline">
            <input type="number" name="Eat_Cheat_Rate" id="Eat_Cheat_Rate" autocomplete="off" class="layui-input" min ="-1000" max="1000" value="[|.RoomInfo.EatCheatRate|]">
        </div>
        <div class="layui-form-mid layui-word-aux">
            <font color="#FF0000" size = "2">
                *该值是千分比，-1000到1000
            </font>
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label" style="display:inline-block;width:150px;">吐分作弊率：</label>
        <div class="layui-input-inline">
            <input type="number" name="Vomit_Cheat_Rate" id="Vomit_Cheat_Rate" autocomplete="off"  class="layui-input" min ="-1000" max="1000" value="[|.RoomInfo.VomitCheatRate|]">
        </div>
        <div class="layui-form-mid layui-word-aux">
            <font color="#FF0000" size = "2">
                *该值是千分比，-1000到1000
            </font>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label" style="display:inline-block;width:150px;">血池平衡值：</label>
        <div class="layui-input-inline">
            <input type="number" name="Room_Blood_Balance" id="Room_Blood_Balance" autocomplete="off"  class="layui-input" value="[|.RoomInfo.RoomBloodBalance|]">
        </div>
        <div class="layui-form-mid layui-word-aux">
            <font color="#FF0000" size = "2">
                *
            </font>
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label" style="display:inline-block;width:150px;">税率：</label>
        <div class="layui-input-inline">
            <input type="number" name="Tax_Rate" id="Tax_Rate" autocomplete="off"  class="layui-input"  min ="0" max="10000" value="[|.RoomInfo.TaxRate|]">
        </div>
        <div class="layui-form-mid layui-word-aux">
            <font color="#FF0000" size = "2">
                 *该值是万分比，0到10000
            </font>
        </div>
    </div>
    
    <div class="layui-form-item">
        <label class="layui-form-label" style="display:inline-block;width:150px;">机器人：</label>
        <div class="layui-input-inline">
            <input type="number" name="Robot_Count" id="Robot_Count" autocomplete="off"  class="layui-input" value="[|.RoomInfo.RobotCount|]">
        </div>
        <div class="layui-form-mid layui-word-aux">
            <font color="#FF0000" size = "2">
                 *
            </font>
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="onputinsure">确定修改</button>
            <button class="layui-btn layui-btn-normal" href="/sysroomconf/list.html" lay-submit="" lay-filter="returlist">返回房间列表</button>
        </div>
    </div>
</form>
</div>

<script>
    var $;

    layui.config({
            base : "js/"
    }).use(['form','element','layer','jquery'], function(){
        var element = layui.element;
        var form = layui.form;
       // var layer = layui.layer
        $ = layui.jquery;
    //监听表格复选框选择
   // table.on('checkbox(demo)', function(obj){
    //   console.log(obj);
   // });

   
    GetMyXiaLaLset()

    //方法级渲染
    form.render("select")
    //监听工具条
   
    form.on('submit(onputinsure)', function(data) {
        
        var selObj = document.getElementById("roomslist");
        var dMinus_Cheat_Rate = document.getElementById("Minus_Cheat_Rate");
        var dEat_Cheat_Rate = document.getElementById("Eat_Cheat_Rate");
        var dVomit_Cheat_Rate = document.getElementById("Vomit_Cheat_Rate");
        var dRoom_Blood_Balance = document.getElementById("Room_Blood_Balance");
        var dTax_Rate = document.getElementById("Tax_Rate");
        var dRobot_Count = document.getElementById("Robot_Count");

        if( dMinus_Cheat_Rate.value==  [|.RoomInfo.MinusCheatRate|] && dEat_Cheat_Rate.value ==  [|.RoomInfo.EatCheatRate|] && dVomit_Cheat_Rate.value == [|.RoomInfo.VomitCheatRate|]&& dRoom_Blood_Balance.value ==   [|.RoomInfo.RoomBloodBalance|] && dTax_Rate.value ==  [|.RoomInfo.TaxRate|] && dRobot_Count.value == [|.RoomInfo.RobotCount|])
        {
            layer.msg("未做任何修改！")
            return false 
        }
        var bmyVerify = MyVerify(dMinus_Cheat_Rate.value,dEat_Cheat_Rate.value,dVomit_Cheat_Rate.value,dTax_Rate.value);
        if(bmyVerify)
        {
        
            layer.confirm('真的要修改【' + selObj.value+'】的配置么？' , function(index){

               var jsData = {
                            'Room_ID':selObj.value
                            ,'Ctrl_Type':2
                            ,'dMinus_Cheat_Rate':dMinus_Cheat_Rate.value
                            ,'dEat_Cheat_Rate':dEat_Cheat_Rate.value
                            ,'dVomit_Cheat_Rate':dVomit_Cheat_Rate.value
                            ,'dRoom_Blood_Balance':dRoom_Blood_Balance.value
                            ,'dTax_Rate':dTax_Rate.value
                            ,'dRobot_Count':dRobot_Count.value
                            }

                $.post('[|urlfor "SysRoomconfController.RoomBooldCtrl"|]', jsData, function (out) {
                    if (out.status == 0) {
                           layer.alert(out.message, {icon: 1},function(index){
                               window.location.href="/sysroomconf/modifyroomconf.html?ServerID="+selObj.value
                               //.RoomInfo.MinusCheatRate = 99999
                            });
                           
                    } else {
                        layer.msg(out.message)
                    }
                }, "json");
            });
            return false;   
        }
        // layer.alert(JSON.stringify(jsData), {
          //      title: '最终的提交信息'
          // }) 
        //return false;
    });
    form.on('submit(returlist)', function(data) {
        window.location.href="/sysroomconf/list.html"
        return false;
    });
    form.on('select(fiterroominfolist)', function(data){
        window.location.href="/sysroomconf/modifyroomconf.html?ServerID="+data.value
        //layer.alert(JSON.stringify(data.value), {
          //title: '最终的提交信息'
         //})
         return false
    });
    return false;
    //return false;
}); 
function GetMyXiaLaLset(){
 
    var selObj = document.getElementById("roomslist");
    //var valObj = document.getElementById("val");
    //var texObj = document.getElementById("tex");
    // 关键是这几句
    var myData = [|.RoomList|]
    var curvalue = [|.curServerID|] 
    for ( var i = 0 ; i < myData.length;i ++)
    {
        var Option = document.createElement("option");
        Option.value = myData[i].ServerID;
        if(curvalue == myData[i].ServerID){
          //   layer.alert(JSON.stringify(curvalue), {
           //     title: '最终的提交信息'
           //}) 
             Option.selected="selected";
        }

        Option.text ="(" + myData[i].ServerID + ")"+ myData[i].RoomName;
        selObj.options.add(Option);
    }
}
function MyVerify(dMinusCheatRate,dEatCheatRate,dVomitCheatRate,dTaxRate)
{

    if(dMinusCheatRate < -1000 || dMinusCheatRate > 1000)
    {
        return false;
    }
    if(dEatCheatRate < -1000 || dEatCheatRate > 1000)
    {
        return false;
    }
    if(dVomitCheatRate < -1000 || dVomitCheatRate > 1000)
    {
        return false;
    }
    if(dTaxRate < 0 || dTaxRate > 10000)
    {
        return false;
    }
    
    return true;
}
</script>
</body>
</html>